package com.hwadee.backend.util;

import com.hwadee.backend.entity.HealthRecord.*;

public class HealthRecordConverter {
    public static HealthRecord convert(HealthRecord baseRecord) {
        String recordType = baseRecord.getRecordType();
        if ("用药记录".equals(recordType)) {
            return new MedicationRecord(
                baseRecord.getRecordId(),
                baseRecord.getRecordDate(),
                baseRecord.getRecordType(),
                baseRecord.getDetail()
            );
        } else if ("家族病史".equals(recordType)) {
            return new FamilyHistory(
                baseRecord.getRecordId(),
                baseRecord.getRecordDate(),
                baseRecord.getRecordType(),
                baseRecord.getDetail()
            );
        } else if ("体检报告".equals(recordType)) {
            return new MedicalExamReport(
                baseRecord.getRecordId(),
                baseRecord.getRecordDate(),
                baseRecord.getRecordType(),
                baseRecord.getDetail()
            );
        } else if ("过敏史".equals(recordType)) {
            return new AllergyHistory(
                baseRecord.getRecordId(),
                baseRecord.getRecordDate(),
                baseRecord.getRecordType(),
                baseRecord.getDetail()
            );
        } else if ("既往病史".equals(recordType)) {
            return new PastMedicalHistory(
                baseRecord.getRecordId(),
                baseRecord.getRecordDate(),
                baseRecord.getRecordType(),
                baseRecord.getDetail()
            );
        } else if ("健康指标".equals(recordType)) {
            return new HealthIndicators(
                baseRecord.getRecordId(),
                baseRecord.getRecordDate(),
                baseRecord.getRecordType(),
                baseRecord.getDetail()
            );
        }
        return baseRecord;
    }
}